package com.qiqi.system_settings.server;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qiqi.pojo.SyCostType;
import com.qiqi.system_settings.mapper.SyCostTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

@Service
public class SyCostTypeImpl implements SyCostTypeService {
    @Autowired
    private SyCostTypeMapper SyCostTypeMapper;

    @Override
    public List<SyCostType> queryAll() {
        QueryWrapper<SyCostType> qw = new QueryWrapper<>();
        qw.eq("kind", 0);
        qw.eq("diskabled", 0);
        return SyCostTypeMapper.selectList(qw);
    }
    @Override
    public List<SyCostType> queryAllFW() {
        QueryWrapper<SyCostType> qw = new QueryWrapper<>();
        qw.eq("kind", 1);
        qw.eq("diskabled", 0);
        return SyCostTypeMapper.selectList(qw);
    }
    @Override
    public int save(SyCostType area) {
        return SyCostTypeMapper.insert(area);
    }

    @Override
    public int update(SyCostType area) {
        return SyCostTypeMapper.updateById(area);
    }

    @Override
    public int del(Serializable id) {
        return SyCostTypeMapper.deleteById(id);
    }

    @Override
    public SyCostType queryByid(Serializable id) {
        return SyCostTypeMapper.selectById(id);
    }
    @Override
    public int delDisable(Serializable id) {
        SyCostType syCostType = SyCostTypeMapper.selectById(id);
        syCostType.setDiskabled(1);
        return SyCostTypeMapper.updateById(syCostType);
    }
}
